<?php
class ControllerProjectProgressDate extends Controller {
private $error = array();

	public function index() {
		$this->language->load('project/progress_date');

		$this->document->setTitle($this->language->get('heading_title'));
		$this->load->model('project/progress_date');
		// var_dump(111);exit;

		$this->getList();
	}

	public function repair() {
		$this->language->load('project/progress_date');

		$this->document->setTitle($this->language->get('heading_title'));

		$this->load->model('project/progress_date');

		if ($this->validateRepair()) {
			$this->model_project_progress_date->repairCategories();

			$this->session->data['success'] = $this->language->get('text_success');

			$this->response->redirect($this->url->link('project/progress_date', 'token=' . $this->session->data['token'], 'SSL'));
		}

		$this->getList();
	}

	protected function getList() {
		// var_dump($this->request->request);exit;
		if (isset($this->request->get['filter_ckg_number'])) {
			$filter_ckg_number = $this->request->get['filter_ckg_number'];
		} else {
			$filter_ckg_number = null;
		}

		if (isset($this->request->get['filter_project_name'])) {
			$filter_project_name = $this->request->get['filter_project_name'];
		} else {
			$filter_project_name = null;
		}

		if (isset($this->request->get['filter_english_name_of_supplier'])) {
			$filter_english_name_of_supplier = $this->request->get['filter_english_name_of_supplier'];
		} else {
			$filter_english_name_of_supplier = null;
		}

		if (isset($this->request->get['filter_status'])) {
			$filter_status = $this->request->get['filter_status'];
		} else {
			$filter_status = null;
		}

		if (isset($this->request->get['filter_customer_name']) && isset($this->request->get['filter_customer_value']) ) {
			$filter_customer_name = $this->request->get['filter_customer_name'];
			$filter_customer_value = $this->request->get['filter_customer_value'];
			// var_dump(111);exit;
		} else {
			$filter_customer_name = null;
			$filter_customer_value = null;
		}


		if (isset($this->request->get['sort'])) {
			$sort = $this->request->get['sort'];
		} else {
			$sort = 'name';
		}

		if (isset($this->request->get['order'])) {
			$order = $this->request->get['order'];
		} else {
			$order = 'DESC';
		}

		if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
		}

		$url = '';
		if (isset($this->request->get['filter_ckg_number'])) {
			$url .= '&filter_ckg_number=' . urlencode(html_entity_decode($this->request->get['filter_ckg_number'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_project_name'])) {
			$url .= '&filter_project_name=' . urlencode(html_entity_decode($this->request->get['filter_project_name'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_english_name_of_supplier'])) {
			$url .= '&filter_english_name_of_supplier=' . urlencode(html_entity_decode($this->request->get['filter_english_name_of_supplier'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_customer_name']) && isset($this->request->get['filter_customer_value']) ) {
			$url .= '&filter_customer_name=' . urlencode(html_entity_decode($this->request->get['filter_customer_name'], ENT_QUOTES, 'UTF-8'));
			$url .= '&filter_customer_value=' . urlencode(html_entity_decode($this->request->get['filter_customer_value'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_status'])) {
			$url .= '&filter_status=' . $this->request->get['filter_status'];
		}

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}

		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}

		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}

		$data['breadcrumbs'] = array();

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_home'),
			'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('heading_title'),
			'href' => $this->url->link('project/progress_date', 'token=' . $this->session->data['token'] . $url, 'SSL')
		);

		$data['add'] = $this->url->link('project/progress_date/add', 'token=' . $this->session->data['token'] . $url, 'SSL');
		$data['delete'] = $this->url->link('project/progress_date/delete', 'token=' . $this->session->data['token'] . $url, 'SSL');
		$data['repair'] = $this->url->link('project/progress_date/repair', 'token=' . $this->session->data['token'] . $url, 'SSL');

		$data['projects'] = array();

		$filter_data = array(
			'filter_ckg_number'	  => $filter_ckg_number,
			'filter_project_name'	  => $filter_project_name,
			'filter_english_name_of_supplier' => $filter_english_name_of_supplier,
			'filter_customer_value'   => $filter_customer_value,
			'filter_customer_name'   => $filter_customer_name,
			'filter_status'   => $filter_status,
			'sort'  => $sort,
			'order' => $order,
			'start' => ($page - 1) * $this->config->get('config_limit_admin'),
			'limit' => $this->config->get('config_limit_admin')
		);
		$category_total = $this->model_project_progress_date->getTotalCategories($filter_data);
		// var_dump($filter_data);exit;
		$results = $this->model_project_progress_date->getProjectProgresslist($filter_data);
		// var_dump($results);exit;
		// var_dump(111);exit;
		foreach ($results as $result) {
			// var_dump((!empty($result['data']['no_1']))?substr($result['data']['no_1']['file_url'],54):'');exit;
			$vendor_details_id_1 = (!empty($result['vendor_details_id_1']))?$this->url->link('vendor/vendor_details/edit', 'token=' . $this->session->data['token'] . '&vendor_details_id=' . $result['vendor_details_id_1'] . $url, 'SSL'):'';

			$vendor_details_id_2 = (!empty($result['vendor_details_id_2']))?$this->url->link('vendor/vendor_details/edit', 'token=' . $this->session->data['token'] . '&vendor_details_id=' . $result['vendor_details_id_2'] . $url, 'SSL'):'';

			$vendor_details_id_3 = (!empty($result['vendor_details_id_3']))?$this->url->link('vendor/vendor_details/edit', 'token=' . $this->session->data['token'] . '&vendor_details_id=' . $result['vendor_details_id_3'] . $url, 'SSL'):'';

			$data['projects'][] = array(
<<<<<<< HEAD
<<<<<<< HEAD
				'project_progress_id'          => $result['project_progress_id'],
				'ckg_number'                   => $result['ckg_number'],
				'project_name'                 => $result['project_name'],
				'project_customer'             => $result['data']['project_customer'],
				
				'submission_date'              => (!empty($result['submission_date']))?date("Y-m-d",(int)$result['submission_date']):'',
				'approval_date'                => (!empty($result['approval_date']))?date("Y-m-d",(int)$result['approval_date']):'',
				'agreement_date'               => (!empty($result['agreement_date']))?date("Y-m-d",(int)$result['agreement_date']):'',
				'date_for_submission_of_grant' => (!empty($result['date_for_submission_of_grant']))?date("Y-m-d",(int)$result['date_for_submission_of_grant']):'',
				'grant_date'                   => (!empty($result['grant_date']))?date("Y-m-d",(int)$result['grant_date']):'',
				
				'project_end_date'             => (!empty($result['project_end_date']))?date("Y-m-d",(int)$result['project_end_date']):'',
				
				'ckg_number_msg'               => (isset($result['ckg_number_msg']))?$result['ckg_number_msg']:'',
				
				'edit'                         => $this->url->link('project/project_progress/edit', 'token=' . $this->session->data['token'] . '&project_progress_id=' . $result['project_progress_id'] . $url, 'SSL'),
				'delete'                       => $this->url->link('project/progress_date/delete', 'token=' . $this->session->data['token'] . '&project_progress_id=' . $result['project_progress_id'] . $url, 'SSL'),
				'vendor_edit_1'                => $vendor_details_id_1,
				'vendor_edit_2'                => $vendor_details_id_2,
				'vendor_edit_3'                => $vendor_details_id_3,
=======
=======
>>>>>>> d186f0ac043b98de93b00ad49075690d01e0cbaa
				'project_progress_id' => $result['project_progress_id'],
				'ckg_number' => $result['ckg_number'],
				'project_name' => $result['project_name'],
				'project_customer' => $result['data']['project_customer'],

				'submission_date' => (!empty($result['submission_date']))?date("Y-m-d",(int)$result['submission_date']):'',
				'approval_date' => (!empty($result['approval_date']))?date("Y-m-d",(int)$result['approval_date']):'',
				'agreement_date' => (!empty($result['agreement_date']))?date("Y-m-d",(int)$result['agreement_date']):'',
				'date_for_submission_of_grant' => (!empty($result['date_for_submission_of_grant']))?date("Y-m-d",(int)$result['date_for_submission_of_grant']):'',
				'grant_date' => (!empty($result['grant_date']))?date("Y-m-d",(int)$result['grant_date']):'',
				
				'ckg_number_msg' => (isset($result['ckg_number_msg']))?$result['ckg_number_msg']:'',

				'edit'        => $this->url->link('project/project_progress/edit', 'token=' . $this->session->data['token'] . '&project_progress_id=' . $result['project_progress_id'] . $url, 'SSL'),
				'delete'      => $this->url->link('project/progress_date/delete', 'token=' . $this->session->data['token'] . '&project_progress_id=' . $result['project_progress_id'] . $url, 'SSL'),
				'vendor_edit_1' => $vendor_details_id_1,
				'vendor_edit_2' => $vendor_details_id_2,
				'vendor_edit_3' => $vendor_details_id_3,
<<<<<<< HEAD
>>>>>>> d186f0ac043b98de93b00ad49075690d01e0cbaa
=======
>>>>>>> d186f0ac043b98de93b00ad49075690d01e0cbaa
			);

		}
		// var_dump($data['projects']);exit;
<<<<<<< HEAD
<<<<<<< HEAD
		$data['heading_title']                       = $this->language->get('heading_title');
		
		$data['text_list']                           = $this->language->get('text_list');
		$data['text_no_results']                     = $this->language->get('text_no_results');
		$data['text_confirm']                        = $this->language->get('text_confirm');
		
		$data['text_status_1']                       = $this->language->get('text_status_1');
		$data['text_status_2']                       = $this->language->get('text_status_2');
		$data['text_status_3']                       = $this->language->get('text_status_3');
		$data['text_status_4']                       = $this->language->get('text_status_4');
		$data['text_status_4']                       = $this->language->get('text_status_4');
		$data['text_status_0']                       = $this->language->get('text_status_0');
		
		$data['button_filter']                       = $this->language->get('button_filter');
		
		$data['column_customer_search']              = $this->language->get('column_customer_search');
		
		$data['column_project_customer_search']      = $this->language->get('column_project_customer_search');
		$data['column_name']                         = $this->language->get('column_name');
		$data['column_sort_order']                   = $this->language->get('column_sort_order');
		$data['column_action']                       = $this->language->get('column_action');
		//project
		$data['column_ckg_number']                   = $this->language->get('column_ckg_number');
		$data['column_project_name']                 = $this->language->get('column_project_name');
		$data['column_no_1']                         = $this->language->get('column_no_1');
		$data['column_no_2']                         = $this->language->get('column_no_2');
		$data['column_no_3']                         = $this->language->get('column_no_3');
		$data['column_no_4']                         = $this->language->get('column_no_4');
		$data['column_no_5']                         = $this->language->get('column_no_5');
		$data['column_no_6']                         = $this->language->get('column_no_6');
		$data['column_no_7']                         = $this->language->get('column_no_7');
		$data['column_no_8']                         = $this->language->get('column_no_8');
		$data['column_no_9']                         = $this->language->get('column_no_9');
		$data['column_no_10']                        = $this->language->get('column_no_10');
		$data['column_no_11']                        = $this->language->get('column_no_11');
		$data['column_no_12']                        = $this->language->get('column_no_12');
		$data['column_no_13']                        = $this->language->get('column_no_13');
		$data['column_no_14']                        = $this->language->get('column_no_14');
		$data['column_no_15']                        = $this->language->get('column_no_15');
		$data['column_no_16']                        = $this->language->get('column_no_16');
		$data['column_no_17']                        = $this->language->get('column_no_17');
		$data['column_confirm']                      = $this->language->get('column_confirm');
		$data['column_follow_up_history']            = $this->language->get('column_follow_up_history');
		$data['column_remark']                       = $this->language->get('column_remark');
		$data['column_status']                       = $this->language->get('column_status');
		
		$data['column_submission_date']              = $this->language->get('column_submission_date');
		$data['column_approval_date']                = $this->language->get('column_approval_date');
		$data['column_agreement_date']               = $this->language->get('column_agreement_date');
		$data['column_date_for_submission_of_grant'] = $this->language->get('column_date_for_submission_of_grant');
		$data['column_grant_date']                   = $this->language->get('column_grant_date');
		$data['column_project_end_date']             = $this->language->get('column_project_end_date');
		
		$data['column_project_customer']             = $this->language->get('column_project_customer');
		$data['column_vendor_1']                     = $this->language->get('column_vendor_1');
		$data['column_vendor_2']                     = $this->language->get('column_vendor_2');
		$data['column_vendor_3']                     = $this->language->get('column_vendor_3');
		
		
		$data['button_add']                          = $this->language->get('button_add');
		$data['button_edit']                         = $this->language->get('button_edit');
		$data['button_delete']                       = $this->language->get('button_delete');
		$data['button_rebuild']                      = $this->language->get('button_rebuild');
=======
=======
>>>>>>> d186f0ac043b98de93b00ad49075690d01e0cbaa
		$data['heading_title'] = $this->language->get('heading_title');

		$data['text_list'] = $this->language->get('text_list');
		$data['text_no_results'] = $this->language->get('text_no_results');
		$data['text_confirm'] = $this->language->get('text_confirm');

		$data['text_status_1'] = $this->language->get('text_status_1');
		$data['text_status_2'] = $this->language->get('text_status_2');
		$data['text_status_3'] = $this->language->get('text_status_3');
		$data['text_status_4'] = $this->language->get('text_status_4');
		$data['text_status_4'] = $this->language->get('text_status_4');
		$data['text_status_0'] = $this->language->get('text_status_0');

		$data['button_filter'] = $this->language->get('button_filter');

		$data['column_customer_search'] = $this->language->get('column_customer_search');

		$data['column_project_customer_search'] = $this->language->get('column_project_customer_search');
		$data['column_name'] = $this->language->get('column_name');
		$data['column_sort_order'] = $this->language->get('column_sort_order');
		$data['column_action'] = $this->language->get('column_action');
		//project
		$data['column_ckg_number'] = $this->language->get('column_ckg_number');
		$data['column_project_name'] = $this->language->get('column_project_name');
		$data['column_no_1'] = $this->language->get('column_no_1');
		$data['column_no_2'] = $this->language->get('column_no_2');
		$data['column_no_3'] = $this->language->get('column_no_3');
		$data['column_no_4'] = $this->language->get('column_no_4');
		$data['column_no_5'] = $this->language->get('column_no_5');
		$data['column_no_6'] = $this->language->get('column_no_6');
		$data['column_no_7'] = $this->language->get('column_no_7');
		$data['column_no_8'] = $this->language->get('column_no_8');
		$data['column_no_9'] = $this->language->get('column_no_9');
		$data['column_no_10'] = $this->language->get('column_no_10');
		$data['column_no_11'] = $this->language->get('column_no_11');
		$data['column_no_12'] = $this->language->get('column_no_12');
		$data['column_no_13'] = $this->language->get('column_no_13');
		$data['column_no_14'] = $this->language->get('column_no_14');
		$data['column_no_15'] = $this->language->get('column_no_15');
		$data['column_no_16'] = $this->language->get('column_no_16');
		$data['column_no_17'] = $this->language->get('column_no_17');
		$data['column_confirm'] = $this->language->get('column_confirm');
		$data['column_follow_up_history'] = $this->language->get('column_follow_up_history');
		$data['column_remark'] = $this->language->get('column_remark');
		$data['column_status'] = $this->language->get('column_status');

		$data['column_submission_date'] = $this->language->get('column_submission_date');
		$data['column_approval_date'] = $this->language->get('column_approval_date');
		$data['column_agreement_date'] = $this->language->get('column_agreement_date');
		$data['column_date_for_submission_of_grant'] = $this->language->get('column_date_for_submission_of_grant');
		$data['column_grant_date'] = $this->language->get('column_grant_date');

		$data['column_project_customer'] = $this->language->get('column_project_customer');
		$data['column_vendor_1'] = $this->language->get('column_vendor_1');
		$data['column_vendor_2'] = $this->language->get('column_vendor_2');
		$data['column_vendor_3'] = $this->language->get('column_vendor_3');


		$data['button_add'] = $this->language->get('button_add');
		$data['button_edit'] = $this->language->get('button_edit');
		$data['button_delete'] = $this->language->get('button_delete');
		$data['button_rebuild'] = $this->language->get('button_rebuild');
<<<<<<< HEAD
>>>>>>> d186f0ac043b98de93b00ad49075690d01e0cbaa
=======
>>>>>>> d186f0ac043b98de93b00ad49075690d01e0cbaa


		$data['token'] = $this->session->data['token'];

		if (isset($this->error['warning'])) {
			$data['error_warning'] = $this->error['warning'];
		} else {
			$data['error_warning'] = '';
		}

		if (isset($this->session->data['success'])) {
			$data['success'] = $this->session->data['success'];

			unset($this->session->data['success']);
		} else {
			$data['success'] = '';
		}

		if (isset($this->request->post['selected'])) {
			$data['selected'] = (array)$this->request->post['selected'];
		} else {
			$data['selected'] = array();
		}

		$url = '';



		if (isset($this->request->get['filter_ckg_number'])) {
			$url .= '&filter_ckg_number=' . urlencode(html_entity_decode($this->request->get['filter_ckg_number'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_project_name'])) {
			$url .= '&filter_project_name=' . urlencode(html_entity_decode($this->request->get['filter_project_name'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_english_name_of_supplier'])) {
			$url .= '&filter_english_name_of_supplier=' . urlencode(html_entity_decode($this->request->get['filter_english_name_of_supplier'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_customer_name']) && isset($this->request->get['filter_customer_value']) ) {
			$url .= '&filter_customer_name=' . urlencode(html_entity_decode($this->request->get['filter_customer_name'], ENT_QUOTES, 'UTF-8'));
			$url .= '&filter_customer_value=' . urlencode(html_entity_decode($this->request->get['filter_customer_value'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_status'])) {
			$url .= '&filter_status=' . $this->request->get['filter_status'];
		}


		if ($order == 'ASC') {
			$url .= '&order=DESC';
		} else {
			$url .= '&order=ASC';
		}

		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}

		$data['sort_ckg_number'] = $this->url->link('project/progress_date', 'token=' . $this->session->data['token'] . '&sort=ckg_number' . $url, 'SSL');
		$data['sort_project_name'] = $this->url->link('project/progress_date', 'token=' . $this->session->data['token'] . '&sort=project_name' . $url, 'SSL');
		$data['sort_status'] = $this->url->link('project/progress_date', 'token=' . $this->session->data['token'] . '&sort=status' . $url, 'SSL');

		$url = '';

		if (isset($this->request->get['filter_ckg_number'])) {
			$url .= '&filter_ckg_number=' . urlencode(html_entity_decode($this->request->get['filter_ckg_number'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_project_name'])) {
			$url .= '&filter_project_name=' . urlencode(html_entity_decode($this->request->get['filter_project_name'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_english_name_of_supplier'])) {
			$url .= '&filter_english_name_of_supplier=' . urlencode(html_entity_decode($this->request->get['filter_english_name_of_supplier'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_customer_name']) && isset($this->request->get['filter_customer_value']) ) {
			$url .= '&filter_customer_name=' . urlencode(html_entity_decode($this->request->get['filter_customer_name'], ENT_QUOTES, 'UTF-8'));
			$url .= '&filter_customer_value=' . urlencode(html_entity_decode($this->request->get['filter_customer_value'], ENT_QUOTES, 'UTF-8'));
		}

		if (isset($this->request->get['filter_status'])) {
			$url .= '&filter_status=' . $this->request->get['filter_status'];
		}

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}



		$pagination = new Pagination();
		$pagination->total = $category_total;
		$pagination->page = $page;
		$pagination->limit = $this->config->get('config_limit_admin');
		$pagination->url = $this->url->link('project/progress_date', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');

		$data['pagination'] = $pagination->render();

		$data['results'] = sprintf($this->language->get('text_pagination'), ($category_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($category_total - $this->config->get('config_limit_admin'))) ? $category_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $category_total, ceil($category_total / $this->config->get('config_limit_admin')));

		$data['filter_ckg_number'] = $filter_ckg_number;
		$data['filter_project_name'] = $filter_project_name;
		$data['filter_english_name_of_supplier'] = $filter_english_name_of_supplier;
		$data['filter_customer_name'] = $filter_customer_name;
		$data['filter_customer_value'] = $filter_customer_value;
		$data['filter_status'] = $filter_status;

		$data['sort'] = $sort;
		$data['order'] = $order;

		$data['header'] = $this->load->controller('common/header');
		$data['column_left'] = $this->load->controller('common/column_left');
		$data['footer'] = $this->load->controller('common/footer');
		$data['status_all'] = $this->model_project_progress_date->getProjectStatus();
		// var_dump(111);exit;
		$this->response->setOutput($this->load->view('project/progress_date_list.tpl', $data));
	}

	

	

	protected function validateRepair() {
		if (!$this->user->hasPermission('modify', 'project/progress_date')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		return !$this->error;
	}
	public function autocomplete() {
		$json = array();

		if (isset($this->request->get['filter_ckg_number']) || isset($this->request->get['filter_project_name']) ) {
			$this->load->model('project/progress_date');
			if (isset($this->request->get['filter_ckg_number'])) {
				$filter_ckg_number = $this->request->get['filter_ckg_number'];
			} else {
				$filter_ckg_number = '';
			}

			if (isset($this->request->get['filter_project_name'])) {
				$filter_project_name = $this->request->get['filter_project_name'];
			} else {
				$filter_project_name = '';
			}

			if (isset($this->request->get['limit'])) {
				$limit = $this->request->get['limit'];
			} else {
				$limit = 5;
			}

			$filter_data = array(
				'filter_ckg_number'  => $filter_ckg_number,
				'filter_project_name' => $filter_project_name,
				'start'        => 0,
				'limit'        => $limit
			);

			$results = $this->model_project_progress_date->getVendorChecklists($filter_data);
			// var_dump($results);exit;
			foreach ($results as $result) {
				$json[] = array(
					'project_progress_id' => $result['project_progress_id'],
					'ckg_number'        => strip_tags(html_entity_decode($result['ckg_number'], ENT_QUOTES, 'UTF-8')),
					'project_name'        => strip_tags(html_entity_decode($result['project_name'], ENT_QUOTES, 'UTF-8'))
				);
			}
		}



		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}

	public function autocomplete2() {
		$json = array();

		if (isset($this->request->get['filter_name'])) {
			$this->load->model('project/progress_date');

			$filter_data = array(
				'filter_name' => $this->request->get['filter_name'],
				'sort'        => 'name',
				'order'       => 'ASC',
				'start'       => 0,
				'limit'       => 5
			);

			$results = $this->model_project_progress_date->getPojectCustomers($filter_data);

			foreach ($results as $result) {
				$json[] = array(
					'project_customer_id' => $result['project_customer_id'],
					'name'        => strip_tags(html_entity_decode($result['company_eng_name'], ENT_QUOTES, 'UTF-8'))
				);
			}
		}

		$sort_order = array();

		foreach ($json as $key => $value) {
			$sort_order[$key] = $value['name'];
		}

		array_multisort($sort_order, SORT_ASC, $json);

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}


	public function autocomplete3() {
		$json = array();

		if (isset($this->request->get['filter_name'])) {
			$this->load->model('project/progress_date');

			$filter_data = array(
				'filter_name' => $this->request->get['filter_name'],
				'start'       => 0,
				'limit'       => 5
			);

			$results = $this->model_project_progress_date->getPojectVendor($filter_data);

			foreach ($results as $result) {
				$json[] = array(
					'vendor_details_id' => $result['vendor_details_id'],
					'name'        => strip_tags(html_entity_decode($result['english_name_of_supplier'], ENT_QUOTES, 'UTF-8'))
				);
			}
		}

		$sort_order = array();

		foreach ($json as $key => $value) {
			$sort_order[$key] = $value['name'];
		}

		array_multisort($sort_order, SORT_ASC, $json);

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}


	
}